#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
// 找到第一个小于等于target的元素
auto findFirstLessOrEqual(vector<long long>& vec, long long target) {
    int left = 0;
    int right = vec.size() - 1;
    int pos = -1;
    
    while (left <= right) {
        int mid = left + (right - left) / 2;
        if (vec[mid] <= target) {
            pos = mid;
            left = mid + 1;  // 继续向右找，看是否有更大的符合条件的值
        } else {
            right = mid - 1;
        }
    } 
    return (pos == -1) ? vec.end() : vec.begin() + pos;
}

void getcoin(vector<long long>& coin, long long& player) {
  if (player < coin.front()) {
    player += coin.front();
    coin.erase(coin.begin());
  } else {
    if (player >= coin.back()) {
      player += coin.back();
      coin.pop_back();
    } else {
      auto it = upper_bound(coin.begin(), coin.end(), player) - 1;
      player += *it;
      coin.erase(it);
    }
  }
  return ;
}

// void output(vector<long long>& coin) {
//   for (auto it = coin.begin(); it != coin.end(); it++) {
//     cout << *it << " ";
//   }
//   cout << endl;
// }

int main() {
  int n;
  cin >> n;
  vector<long long> coin;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    coin.push_back(x);
  }
  sort(coin.begin(), coin.end());
  long long player1 = 0, player2 = 0;
  // int cnt = 1;
  while (!coin.empty()) {
    // cout << "round :" << cnt << endl;
    getcoin(coin, player1);
    // output(coin);
    // cout << "player1: " << player1 << endl;
    // cout << "----------------" << endl;
    if (coin.empty()) break;
    getcoin(coin, player2);
    // output(coin);
    // cout << "player2: " << player2 << endl;
    // cout << "----------------" << endl;
    // cnt++;
  }
  cout << player1 << " " << player2 << endl;
  return 0;
}
